from PyQt5.QtWidgets import QApplication, QMainWindow, QSlider
from PyQt5.QtCore import Qt

class MySlider(QSlider):
    def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            self.setValue(self.minimum() + (self.maximum() - self.minimum()) * event.x() / self.width())
        event.accept()

    def mouseMoveEvent(self, event):
        if event.buttons() & Qt.LeftButton:
            self.setValue(self.minimum() + (self.maximum() - self.minimum()) * event.x() / self.width())

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        slider = MySlider(Qt.Horizontal, self)
        slider.setRange(0, 100)
        slider.setValue(50)
        slider.setGeometry(30, 40, 200, 30)

if __name__ == '__main__':
    app = QApplication([])
    window = MainWindow()
    window.show()
    app.exec_()